home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / egs-tools / egs_dev-disk / egsdemos / moreexamples / onegadget / onegadget.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-06  |  2.8 KB  |  87 lines

  1.                        /* onegadget.c
  2.                           Simple little program showing one gadget in
  3.                           a verti box. See the gadget overview doc for
  4.                           details.
  5.                           Patrick Hager, Great Valley Products Inc.
  6.                           October 29, 1993
  7.                        */
  8.  
  9.  
  10.  
  11. #include <stdio.h>
  12. #include "/userwindow.h"
  13. #include "/egslibraries.h"
  14.  
  15. #include <egs/egsintui.h>
  16. #include <egs/clib/egsintui_protos.h>
  17. #include <egs/pragmas/egsintui_pragmas.h>
  18. #include <egs/egsgadbox.h>
  19. #include <egs/clib/egsgadbox_protos.h>
  20. #include <egs/pragmas/egsgadbox_pragmas.h>
  21.  
  22. #define TESTING_ID 200
  23.  
  24.  
  25. struct UserInputWindow Example_Request;
  26.  
  27. EB_GadBoxPtr Create_Example (UserInputWindowPtr UserWindow);
  28. void GadgetDown_Example (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress);
  29.  
  30. void main (void) {
  31.  
  32.   if (OpenEGSLibraries ()) {
  33.     Init_UserWindow (&Example_Request, "Example Window",WINDOW_MODAL,NULL,
  34.                      NULL);
  35.     Example_Request.Create = Create_Example;
  36.     Example_Request.GadgetDown = GadgetDown_Example;
  37.     Example_Request.IDCMPFlags = EI_iCLOSEWINDOW | EI_iSIZEVERIFY |
  38.                                  EI_iNEWSIZE | EI_iGADGETDOWN;
  39.     Example_Request.Flags =      EI_SIZEBBOTTOM| EI_SIMPLE_REFRESH |
  40.                                  EI_GIMMEZEROZERO;
  41.     Example_Request.SysGadgets = (EI_WINDOWCLOSE)|(EI_WINDOWSIZE)|EI_WINDOWDRAG;
  42.  
  43.     if (Open_UserWindow (&Example_Request,-1,-1)) {
  44.       Close_UserWindow (&Example_Request);
  45.     }
  46.     else
  47.       printf ("Couldn't open my window!\n");
  48.   }
  49.   CloseEGSLibraries ();  // after the bracket cause what if I opened 3 but
  50.                          // couldn't find the rest, still need to close the 3.
  51. }
  52.  
  53. /*************************************
  54.    PRIVATE:  Create_Example.
  55.              This routine is called by the UserWindow routines.
  56.              It passes back a GadBoxPtr to the gadgets wanted.
  57. *************************************/
  58. EB_GadBoxPtr Create_Example (UserInputWindowPtr UserWindow) {
  59.   EB_GadBoxPtr root,help;
  60.   EB_GadContext gadcon;
  61.  
  62.   gadcon = UserWindow->GadCon;
  63.   root = EB_CreateVertiBox (gadcon);
  64.   EB_AddLastSon (root,EB_CreateVertiFill (gadcon,0,0));
  65.   help=EB_CreateTextAction (gadcon,"Testing 1,2,3",TESTING_ID,EB_FILL_ALL);
  66.   EB_NewPri (help,-1);
  67.   EB_AddLastSon (root,help);
  68.  
  69.  
  70.   EB_AddLastSon (root,EB_CreateVertiFill (gadcon,0,0));
  71.   return root;
  72. }
  73.  
  74. /**************************************
  75.     PRIVATE:  GadgetDown_Example.
  76.               This routine handles the gadget down events passed to the
  77.               Example Control Window.
  78. **************************************/
  79. void GadgetDown_Example (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress) {
  80.  
  81.  
  82.   switch (iaddress->GadgetID) {
  83.     case TESTING_ID:
  84.       printf ("You hit me!\n");
  85.     break;
  86.   }
  87. }